package game;

import org.lwjgl.util.vector.Vector3f;

public class Entity {
	protected World world;
	protected Vector3f pos, rot, size;
	public float speed = 0.1f;
	public float height = 10f;
	public AABB collision;

	public Entity(World world, Vector3f pos) {
		this.world = world;
		this.pos = pos;
		rot = new Vector3f();
		size = new Vector3f(1, 1, 1);
		collision = new AABB(pos.x, pos.y, pos.z, size.x, size.y, size.z);
	}

	public void update(int delta) {

	}

	public void render() {

	}

	public void move(Vector3f vec) {
		if (vec.x != 0 && vec.z != 0) {
			move(new Vector3f(vec.x, 0, 0));
			move(new Vector3f(0, vec.y, 0));
			move(new Vector3f(0, 0, vec.z));
			return;
		}
		for (int i = 0; i < world.getBoxes().size(); i++) {
			AABB bcol = world.getBoxes().get(i).collision;
			if (collision.canMove(bcol, vec.x, vec.y, vec.z))
				return;
		}
		pos.x += vec.x;
		pos.y += vec.y;
		pos.z += vec.z;
		collision.setPos(pos);
	}

	public void setRot(Vector3f rot) {
		this.rot = rot;
	}

	public Vector3f getPos() {
		return pos;
	}

	public Vector3f getRot() {
		return rot;
	}
}
